/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mucp.server;

import java.io.IOException;
import java.net.ServerSocket;
import mucp.ControlProtocol.ControlProtocol;

/**
 *
 * @author niklas
 */
public class ProtocolServer {
    public void setup()
    {
        ServerSocket serverSocket = null;
        ControlProtocol protocol = new ControlProtocol();
        boolean listening = true;
        int serverListingPort = protocol.getServerListingPort();

        try {
            serverSocket = new ServerSocket(serverListingPort);
        } catch (IOException e) {
            System.err.println("Could not listen on port: " + serverListingPort);
            System.exit(-1);
        }
        
        while (listening)
	    new ServerThread(serverSocket.accept()).start();

        serverSocket.close();

    }
}
